<script setup lang="ts">
import { useRouter } from 'vue-router'
const router = useRouter()
function goTo(path: string) {
  router.push(path)
}
</script>

<template>
  <div class="flowchart">
    <!-- 顶部主节点 -->
    <div class="node main-node" @click="goTo('/')">
      <span>我的项目</span>
    </div>
    <svg class="line" width="4" height="48">
      <line x1="2" y1="0" x2="2" y2="48" stroke="#7e57c2" stroke-width="4" stroke-linecap="round"/>
    </svg>
    <div class="row">
      <!-- 左侧分支 -->
      <div class="branch">
        <div class="node sub-node" @click="goTo('/')">存储用户项目文件</div>
        <svg class="line" width="4" height="48">
          <line x1="2" y1="0" x2="2" y2="48" stroke="#42a5f5" stroke-width="4" stroke-linecap="round"/>
        </svg>
        <div class="row">
          <div class="node leaf-node" @click="goTo('/completed')">已完成项目</div>
          <div class="node leaf-node" @click="goTo('/inprogress')">进行中项目</div>
          <div class="node leaf-node" @click="goTo('/download')">下载他人项目</div>
        </div>
      </div>
      <!-- 右侧分支 -->
      <div class="branch">
        <div class="node sub-node" @click="goTo('/')">新建文件</div>
        <svg class="line" width="4" height="48">
          <line x1="2" y1="0" x2="2" y2="48" stroke="#42a5f5" stroke-width="4" stroke-linecap="round"/>
        </svg>
        <div class="row">
          <div class="node leaf-node" @click="goTo('/toolbox')">工具箱模式</div>
          <div class="node leaf-node" @click="goTo('/developer')">开发者模式</div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.flowchart {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: 'Poppins', 'Segoe UI', 'PingFang SC', 'Hiragino Sans', Arial, sans-serif;
  padding: 32px 0;
  background: none;
}

.node {
  min-width: 150px;
  min-height: 56px;
  background: linear-gradient(100deg, #e3f2fd 60%, #ede7f6 100%);
  border-radius: 18px;
  margin: 0 18px 12px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px 0 rgba(66, 133, 244, 0.10), 0 1.5px 6px 0 rgba(126, 87, 194, 0.10);
  cursor: pointer;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1px;
  user-select: none;
  transition: box-shadow 0.2s, background 0.2s, transform 0.15s;
  position: relative;
  z-index: 2;
  border: 1.5px solid #b39ddb33;
}
.node:hover {
  background: linear-gradient(100deg, #bbdefb 60%, #d1c4e9 100%);
  box-shadow: 0 12px 32px 0 rgba(66, 133, 244, 0.18), 0 3px 12px 0 rgba(126, 87, 194, 0.18);
  transform: translateY(-2px) scale(1.03);
}

.main-node {
  background: linear-gradient(90deg, #7e57c2 0%, #42a5f5 100%);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 2px;
  box-shadow: 0 8px 32px 0 rgba(126, 87, 194, 0.18), 0 2px 8px 0 rgba(66, 133, 244, 0.12);
  border: none;
}

.sub-node {
  background: linear-gradient(90deg, #e3f2fd 60%, #ede7f6 100%);
  color: #5e35b1;
  font-size: 18px;
  font-weight: 600;
}

.leaf-node {
  min-width: 120px;
  min-height: 44px;
  font-size: 16px;
  background: linear-gradient(90deg, #fff 60%, #e3f2fd 100%);
  color: #1976d2;
  font-weight: 500;
  border-radius: 14px;
  border: 1px solid #90caf955;
  margin: 0 10px 8px 10px;
}

.row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  margin-bottom: 8px;
}

.branch {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0 40px;
}

.line {
  display: block;
  margin-bottom: -8px;
}

@media (max-width: 900px) {
  .row {
    flex-direction: column;
    align-items: center;
  }
  .branch {
    margin: 0 0 32px 0;
  }
  .flowchart {
    padding: 12px 0;
  }
}
</style>
